#!/bin/ksh
#
# GenericRdist -- generically rdist lsof 4.x sources to a specified destination
#
# Usage: GenericRdist <destination> <dialect> <shell>
#
#	 <destination>	destination host
#
#	 <dialect>	dialect subdirectory name
#
#	 <shell>	remote shell -- rsh or ssh

# Process arguments.

if test $# -ne 3
then
  echo "Usage: <destination> <dialect> <shell>"
  exit
fi
H=$1
D=$2
S=$3

# Test the shell and define its full path, as required.

if test "X$S" = "Xrsh"
then
  SHP=""
else
  if test "X$S" = "Xssh"
  then
    SHP="-P /opt/openssh/bin/ssh"
  else
    echo "$S is not an acceptable shell; specify rsh or ssh."
    exit
  fi
fi

# Define the distfile and make sure it's removed on premature exit.

R=/tmp/distfile.$$
trap 'rm $R; exit 1' 1 2 3 15

rm -f $R
cat > $R << .DISTFILE
. -> $H
	except ( ./00.README.FIRST ./00DCACHE ./00DIST ./00FAQ );
	except ( ./00PORTING ./00README ./00CREDITS ./00QUICKSTART );
	except ( ./00LSOF-L ./00MANIFEST ./00XCONFIG ./.ck00MAN );
	except ( ./00TEST ./.neverCust ./.neverInv );
	except ( ./ChangeLog ./Makefile );
	except ( ./lsof ./lsof32 ./lsof64 ./lsof_old /lsof_32.old );
	except ( ./lsof_64.old ./Lsof.8 );
	except ( ./ddev.c ./dfile.c ./dlsof.h ./dmnt.c ./dnode.c ./dnode1.c );
	except ( ./dnode2.c ./dproc.c ./dproto.h ./dsock.c ./dstore.c );
	except ( ./kernelbase.h ./machine.h ./version.h ./zipme );
	except ( ./NEW ./OLD ./RCS ./dialects ./support ) ;
	except ( ./make.out ./new ./old ./out ./X ./xxx ./errs ) ;
	except ( ./lib/Makefile ./lib/RCS ./lib/OLD ./lib/NEW );
	except ( ./scripts/OLD ./scripts/NEW ./scripts/RCS );
	except ( ./scripts/00MANIFEST ./scripts/00README ) ;
	except ( ./tests/OLD ./tests/NEW ./tests/RCS );
	except ( ./tests/00README );
	except ( ./tests/LTbasic ./tests/LTbigf ./tests/LTdnlc );
	except ( ./tests/LTlock ./tests/LTnfs ./tests/LTnlink );
	except ( ./tests/LTsock ./tests/LTszoff ./tests/LTunix );
	except_pat ( \\.o\\$ \\.a\\$ ./tests/config\\. );
	install src/lsof4;

./dialects/$D -> $H
	except ( ./dialects/$D/NEW );
	except ( ./dialects/$D/OLD ./dialects/$D/RCS );
	install src/lsof4/dialects/$D ;
.DISTFILE

# Do the actual distribution.

(cd $HOME/src/lsof4; /usr/local/bin/rdist $SHP -f $R)
rm $R
echo done
